Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
	''' <summary>
	''' Strongly-typed collection for the ClubEvent class.
	''' </summary>
	<Serializable> _
	Public Partial Class ClubEventCollection 
	Inherits ActiveList(Of ClubEvent, ClubEventCollection)
	    Public Sub New()
		End Sub
	End Class
	''' <summary>
	''' This is an ActiveRecord class which wraps the ClubEvent table.
	''' </summary>
	<Serializable> _
	Public Partial Class ClubEvent 
	Inherits ActiveRecord(Of ClubEvent)
		#Region ".ctors and Default Settings"
		
		Public Sub New()
			SetSQLProps()
			InitSetDefaults()
			MarkNew()
		End Sub
		
		Public Sub New(ByVal useDatabaseDefaults As Boolean)
			SetSQLProps()
			If useDatabaseDefaults = True Then
				ForceDefaults()
			End If
			MarkNew()
		End Sub
		Public Sub New(ByVal keyID As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByKey(keyID)
		End Sub
		Public Sub New(ByVal columnName As String, ByVal columnValue As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByParam(columnName,columnValue)
		End Sub
		Private Sub InitSetDefaults()
			SetDefaults()
		End Sub
		
		Protected Shared Sub SetSQLProps()
			GetTableSchema()
		End Sub
		#End Region
		
		#Region "Schema and Query Accessor"
		
		Public Shared ReadOnly Property Schema() As TableSchema.Table
			Get
				If BaseSchema Is Nothing Then
					SetSQLProps()
				End If
				Return BaseSchema
			End Get
		End Property
		Private Shared Sub GetTableSchema()
			If (Not IsSchemaInitialized) Then
				'Schema declaration
				Dim schema As TableSchema.Table = New TableSchema.Table("ClubEvent", TableType.Table, DataService.GetInstance("ClubStarterKitData"))
				schema.Columns = New TableSchema.TableColumnCollection()
				schema.SchemaName = "dbo"
				'columns
				
                
                Dim colvarId As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarId.ColumnName = "ID"
                colvarId.DataType = DbType.Int32
                colvarId.MaxLength = 0
                colvarId.AutoIncrement = true
                colvarId.IsNullable = false
                colvarId.IsPrimaryKey = true
                colvarId.IsForeignKey = false
                colvarId.IsReadOnly = false
                
                
                schema.Columns.Add(colvarId)
                
                Dim colvarStarttime As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarStarttime.ColumnName = "starttime"
                colvarStarttime.DataType = DbType.DateTime
                colvarStarttime.MaxLength = 0
                colvarStarttime.AutoIncrement = false
                colvarStarttime.IsNullable = false
                colvarStarttime.IsPrimaryKey = false
                colvarStarttime.IsForeignKey = false
                colvarStarttime.IsReadOnly = false
                
                
                schema.Columns.Add(colvarStarttime)
                
                Dim colvarEndtime As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEndtime.ColumnName = "endtime"
                colvarEndtime.DataType = DbType.DateTime
                colvarEndtime.MaxLength = 0
                colvarEndtime.AutoIncrement = false
                colvarEndtime.IsNullable = true
                colvarEndtime.IsPrimaryKey = false
                colvarEndtime.IsForeignKey = false
                colvarEndtime.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEndtime)
                
                Dim colvarTitle As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarTitle.ColumnName = "title"
                colvarTitle.DataType = DbType.String
                colvarTitle.MaxLength = 500
                colvarTitle.AutoIncrement = false
                colvarTitle.IsNullable = false
                colvarTitle.IsPrimaryKey = false
                colvarTitle.IsForeignKey = false
                colvarTitle.IsReadOnly = false
                
                
                schema.Columns.Add(colvarTitle)
                
                Dim colvarDescription As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarDescription.ColumnName = "description"
                colvarDescription.DataType = DbType.String
                colvarDescription.MaxLength = 8000
                colvarDescription.AutoIncrement = false
                colvarDescription.IsNullable = true
                colvarDescription.IsPrimaryKey = false
                colvarDescription.IsForeignKey = false
                colvarDescription.IsReadOnly = false
                
                
                schema.Columns.Add(colvarDescription)
                
                Dim colvarStaticURL As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarStaticURL.ColumnName = "staticURL"
                colvarStaticURL.DataType = DbType.String
                colvarStaticURL.MaxLength = 8000
                colvarStaticURL.AutoIncrement = false
                colvarStaticURL.IsNullable = true
                colvarStaticURL.IsPrimaryKey = false
                colvarStaticURL.IsForeignKey = false
                colvarStaticURL.IsReadOnly = false
                
                
                schema.Columns.Add(colvarStaticURL)
                
                Dim colvarPhoto As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarPhoto.ColumnName = "photo"
                colvarPhoto.DataType = DbType.Int32
                colvarPhoto.MaxLength = 0
                colvarPhoto.AutoIncrement = false
                colvarPhoto.IsNullable = false
                colvarPhoto.IsPrimaryKey = false
                colvarPhoto.IsForeignKey = false
                colvarPhoto.IsReadOnly = false
                
                
                schema.Columns.Add(colvarPhoto)
                
                Dim colvarAlbum As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarAlbum.ColumnName = "album"
                colvarAlbum.DataType = DbType.Int32
                colvarAlbum.MaxLength = 0
                colvarAlbum.AutoIncrement = false
                colvarAlbum.IsNullable = true
                colvarAlbum.IsPrimaryKey = false
                colvarAlbum.IsForeignKey = false
                colvarAlbum.IsReadOnly = false
                
                
                schema.Columns.Add(colvarAlbum)
                
                Dim colvarRsvp As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarRsvp.ColumnName = "RSVP"
                colvarRsvp.DataType = DbType.Boolean
                colvarRsvp.MaxLength = 0
                colvarRsvp.AutoIncrement = false
                colvarRsvp.IsNullable = false
                colvarRsvp.IsPrimaryKey = false
                colvarRsvp.IsForeignKey = false
                colvarRsvp.IsReadOnly = false
                
                
                schema.Columns.Add(colvarRsvp)
                
                Dim colvarTotalAttendance As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarTotalAttendance.ColumnName = "TotalAttendance"
                colvarTotalAttendance.DataType = DbType.Int32
                colvarTotalAttendance.MaxLength = 0
                colvarTotalAttendance.AutoIncrement = false
                colvarTotalAttendance.IsNullable = true
                colvarTotalAttendance.IsPrimaryKey = false
                colvarTotalAttendance.IsForeignKey = false
                colvarTotalAttendance.IsReadOnly = false
                
                
                schema.Columns.Add(colvarTotalAttendance)
                
                Dim colvarCurrentAttendance As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarCurrentAttendance.ColumnName = "CurrentAttendance"
                colvarCurrentAttendance.DataType = DbType.Int32
                colvarCurrentAttendance.MaxLength = 0
                colvarCurrentAttendance.AutoIncrement = false
                colvarCurrentAttendance.IsNullable = true
                colvarCurrentAttendance.IsPrimaryKey = false
                colvarCurrentAttendance.IsForeignKey = false
                colvarCurrentAttendance.IsReadOnly = false
                
                
                schema.Columns.Add(colvarCurrentAttendance)
                
                Dim colvarLocationName As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarLocationName.ColumnName = "LocationName"
                colvarLocationName.DataType = DbType.String
                colvarLocationName.MaxLength = 50
                colvarLocationName.AutoIncrement = false
                colvarLocationName.IsNullable = true
                colvarLocationName.IsPrimaryKey = false
                colvarLocationName.IsForeignKey = false
                colvarLocationName.IsReadOnly = false
                
                
                schema.Columns.Add(colvarLocationName)
                
                Dim colvarLocationDirections As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarLocationDirections.ColumnName = "LocationDirections"
                colvarLocationDirections.DataType = DbType.String
                colvarLocationDirections.MaxLength = 50
                colvarLocationDirections.AutoIncrement = false
                colvarLocationDirections.IsNullable = true
                colvarLocationDirections.IsPrimaryKey = false
                colvarLocationDirections.IsForeignKey = false
                colvarLocationDirections.IsReadOnly = false
                
                
                schema.Columns.Add(colvarLocationDirections)
                
				BaseSchema = schema
				
				'add this schema to the provider
                'so we can query it later
                DataService.Providers("ClubStarterKitData").AddSchema("ClubEvent",schema)
			End If
		End Sub
		Public Shared Function CreateQuery() As Query
			Return New Query(Schema)
		End Function
		
		#End Region
		
		#Region "Props"
	
          
        <XmlAttribute("Id")> _
        Public Property Id As Integer 
			Get
				Return GetColumnValue(Of Integer)("ID")
			End Get
		    
			Set
				SetColumnValue("ID", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Starttime")> _
        Public Property Starttime As DateTime 
			Get
				Return GetColumnValue(Of DateTime)("starttime")
			End Get
		    
			Set
				SetColumnValue("starttime", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Endtime")> _
        Public Property Endtime As Nullable(Of DateTime) 
			Get
				Return GetColumnValue(Of Nullable(Of DateTime))("endtime")
			End Get
		    
			Set
				SetColumnValue("endtime", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Title")> _
        Public Property Title As String 
			Get
				Return GetColumnValue(Of String)("title")
			End Get
		    
			Set
				SetColumnValue("title", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Description")> _
        Public Property Description As String 
			Get
				Return GetColumnValue(Of String)("description")
			End Get
		    
			Set
				SetColumnValue("description", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("StaticURL")> _
        Public Property StaticURL As String 
			Get
				Return GetColumnValue(Of String)("staticURL")
			End Get
		    
			Set
				SetColumnValue("staticURL", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Photo")> _
        Public Property Photo As Integer 
			Get
				Return GetColumnValue(Of Integer)("photo")
			End Get
		    
			Set
				SetColumnValue("photo", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Album")> _
        Public Property Album As Nullable(Of Integer) 
			Get
				Return GetColumnValue(Of Nullable(Of Integer))("album")
			End Get
		    
			Set
				SetColumnValue("album", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Rsvp")> _
        Public Property Rsvp As Boolean 
			Get
				Return GetColumnValue(Of Boolean)("RSVP")
			End Get
		    
			Set
				SetColumnValue("RSVP", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("TotalAttendance")> _
        Public Property TotalAttendance As Nullable(Of Integer) 
			Get
				Return GetColumnValue(Of Nullable(Of Integer))("TotalAttendance")
			End Get
		    
			Set
				SetColumnValue("TotalAttendance", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("CurrentAttendance")> _
        Public Property CurrentAttendance As Nullable(Of Integer) 
			Get
				Return GetColumnValue(Of Nullable(Of Integer))("CurrentAttendance")
			End Get
		    
			Set
				SetColumnValue("CurrentAttendance", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("LocationName")> _
        Public Property LocationName As String 
			Get
				Return GetColumnValue(Of String)("LocationName")
			End Get
		    
			Set
				SetColumnValue("LocationName", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("LocationDirections")> _
        Public Property LocationDirections As String 
			Get
				Return GetColumnValue(Of String)("LocationDirections")
			End Get
		    
			Set
				SetColumnValue("LocationDirections", Value)
			End Set
		End Property
		
		
		
		
		#End Region
		
		
			    
	    
		
		
		
		
		
	    
	    'no foreign key tables defined (0)
	    
		
	    
	    'no ManyToMany tables defined (0)
	    
		
		#Region "ObjectDataSource support"
		
		''' <summary>
		''' Inserts a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Insert(ByVal varStarttime As DateTime,ByVal varEndtime As Nullable(Of DateTime),ByVal varTitle As String,ByVal varDescription As String,ByVal varStaticURL As String,ByVal varPhoto As Integer,ByVal varAlbum As Nullable(Of Integer),ByVal varRsvp As Boolean,ByVal varTotalAttendance As Nullable(Of Integer),ByVal varCurrentAttendance As Nullable(Of Integer),ByVal varLocationName As String,ByVal varLocationDirections As String)
			Dim item As ClubEvent = New ClubEvent()
			
            item.Starttime = varStarttime
            
            item.Endtime = varEndtime
            
            item.Title = varTitle
            
            item.Description = varDescription
            
            item.StaticURL = varStaticURL
            
            item.Photo = varPhoto
            
            item.Album = varAlbum
            
            item.Rsvp = varRsvp
            
            item.TotalAttendance = varTotalAttendance
            
            item.CurrentAttendance = varCurrentAttendance
            
            item.LocationName = varLocationName
            
            item.LocationDirections = varLocationDirections
            
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		''' <summary>
		''' Updates a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Update(ByVal varId As Integer,ByVal varStarttime As DateTime,ByVal varEndtime As Nullable(Of DateTime),ByVal varTitle As String,ByVal varDescription As String,ByVal varStaticURL As String,ByVal varPhoto As Integer,ByVal varAlbum As Nullable(Of Integer),ByVal varRsvp As Boolean,ByVal varTotalAttendance As Nullable(Of Integer),ByVal varCurrentAttendance As Nullable(Of Integer),ByVal varLocationName As String,ByVal varLocationDirections As String)
			Dim item As ClubEvent = New ClubEvent()
		    
                item.Id = varId
				
                item.Starttime = varStarttime
				
                item.Endtime = varEndtime
				
                item.Title = varTitle
				
                item.Description = varDescription
				
                item.StaticURL = varStaticURL
				
                item.Photo = varPhoto
				
                item.Album = varAlbum
				
                item.Rsvp = varRsvp
				
                item.TotalAttendance = varTotalAttendance
				
                item.CurrentAttendance = varCurrentAttendance
				
                item.LocationName = varLocationName
				
                item.LocationDirections = varLocationDirections
				
			item.IsNew = False
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		#End Region
		#Region "Columns Struct"
		Public Structure Columns
			Dim x as Integer
			
            Public Shared Id As String = "ID"
            
            Public Shared Starttime As String = "starttime"
            
            Public Shared Endtime As String = "endtime"
            
            Public Shared Title As String = "title"
            
            Public Shared Description As String = "description"
            
            Public Shared StaticURL As String = "staticURL"
            
            Public Shared Photo As String = "photo"
            
            Public Shared Album As String = "album"
            
            Public Shared Rsvp As String = "RSVP"
            
            Public Shared TotalAttendance As String = "TotalAttendance"
            
            Public Shared CurrentAttendance As String = "CurrentAttendance"
            
            Public Shared LocationName As String = "LocationName"
            
            Public Shared LocationDirections As String = "LocationDirections"
            
		End Structure
		#End Region
	End Class
End Namespace
